package com.paris10.model;

import java.util.List;

import org.codehaus.jackson.annotate.JsonSubTypes;  
import org.codehaus.jackson.annotate.JsonSubTypes.Type;  
import org.codehaus.jackson.annotate.JsonTypeInfo;  

@JsonTypeInfo(  
	    use = JsonTypeInfo.Id.NAME,  
	    include = JsonTypeInfo.As.PROPERTY,  
	    property = "type")  
@JsonSubTypes({  
	    @Type(value = FluxRSS.class, name = "FluxRSS"),  
	    @Type(value = Markdown.class, name = "Markdown"),
	    @Type(value = PageWeb.class, name = "PageWeb"),
	    @Type(value = Dossier.class, name = "Dossier")
	    })  
public abstract class AbstractSource implements Source{
	
	protected String titre;
	protected String chemin;
	protected String date;  
	protected int id;
	
	public String getTitre() {
		return titre;
	}

	public void setTitre(String titre) {
		this.titre = titre;
	}

	public String getChemin() {
		return chemin;
	}

	public void setChemin(String chemin) {
		this.chemin = chemin;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public abstract AbstractSource createSource(String titre, String path);
	
	public String toString(){
		return "Id : "+this.id+"\r\nTitre : "+this.titre+"\r\nChemin : "+this.chemin+"\r\nDate d'ajout : "+this.date+"\r\n\r\n";
	}
	
	public boolean equals(Object o){
		if(o == this){
			return true;
		}
		AbstractSource source = (AbstractSource) o;
		if(chemin.equals(source.getChemin()) 
				&& titre.equals(source.getTitre()) 
					&& date.equals(source.getDate()) 
						&& id == source.getId()){
			return true;
		}else{
			return false;
		}
	}
	
	public abstract List<Article> rechercherMotsCles(String[] motsCles);
}
